#include <iostream>
#include <memory>
using namespace std;

class A;
class B;
class A
{
    public:

        ~A()
        {
            cout<<"A类的析构函数被调用"<<endl;
        }

        weak_ptr<B> b_p;
};

class B
{
    public:
        ~B()
        {
            cout<<"B类的析构函数被调用"<<endl;
        }

        weak_ptr<A> a_p;
};

int main(int argc, char const *argv[])
{
    shared_ptr<A> a1(new A);
    shared_ptr<B> b1(new B);

    a1->b_p = b1;
    b1->a_p = a1;

    cout<<"a1的引用计数为:"<<a1.use_count()<<endl;
    cout<<"b1的引用计数为:"<<b1.use_count()<<endl;

    return 0;
}
